Class HCC.DT.HCC2HL72.NewApptBookRequst Extends Ens.DataTransformDTL [ DependsOn = (EnsLib.EDI.XML.Document, EnsLib.HL7.Message) ]
{

Parameter IGNOREMISSINGSOURCE = 1;

Parameter REPORTERRORS = 1;

Parameter TREATEMPTYREPEATINGFIELDASNULL = 0;

XData DTL [ XMLNamespace = "http://www.intersystems.com/dtl" ]
{
<transform sourceClass='EnsLib.EDI.XML.Document' targetClass='EnsLib.HL7.Message' sourceDocType='PRPA_IN400001UV:PRPA_IN400001UV' targetDocType='2.5.1:SRM_S01' create='new' language='objectscript' >
<assign value='source.{id().extension}' property='target.{MSH:MessageControlID}' action='set' />
<assign value='source.{creationTime().value}' property='target.{MSH:DateTimeOfMessage.Time}' action='set' />
<assign value='"SRM"' property='target.{MSH:MessageType.MessageCode}' action='set' />
<assign value='"S01"' property='target.{MSH:MessageType.TriggerEvent}' action='set' />
<assign value='source.{controlActProcess().subject().encounterEvent().subject().patient().id().item().extension}' property='target.{PIDgrp(1).PID:PatientID.IDNumber}' action='set' />
<assign value='source.{controlActProcess().subject().encounterEvent().subject().patient().choice.patientPerson().id.item().extension}' property='target.{PIDgrp().PID:PatientIdentifierList(1).IDNumber}' action='set' />
<assign value='##class(HCC.Utils.Functions).GetDataByXPath(source.{controlActProcess().subject().encounterEvent().subject().patient().choice.patientPerson().name()}, "//s:item/s:part/@value")' property='target.{PIDgrp().PID:PatientName(1)}' action='set' />
<foreach property='source.{controlActProcess().subject().encounterEvent().id().item()}' key='k1' >
<assign value='source.{controlActProcess().subject().encounterEvent().id().item(k1).extension}' property='target.{PIDgrp().PID:AlternatePatientIDPID(k1).IDNumber}' action='set' />
</foreach>
<assign value='source.{controlActProcess().subject().encounterEvent().reasonCode.item().originalText.value}' property='target.{ARQ:AppointmentReason}' action='set' />
<assign value='source.{controlActProcess().subject().encounterEvent().code().displayName.value}' property='target.{ARQ:AppointmentType.Text}' action='set' />
<assign value='source.{controlActProcess().subject().encounterEvent().code().code}' property='target.{ARQ:AppointmentType.Identifier}' action='set' />
<assign value='source.{controlActProcess().subject().encounterEvent().effectiveTime().low.value}' property='target.{ARQ:RequestedStartDateTimeRange(1).RangeStartDateTime.Time}' action='set' />
<assign value='source.{controlActProcess().subject().encounterEvent().admitter.assignedPerson().id.item().extension}' property='target.{ARQ:EnteredByPerson(1).IDNumber}' action='set' />
<assign value='##class(HCC.Utils.Functions).GetDataByXPath(source.{controlActProcess().subject().encounterEvent().admitter.assignedPerson().assignedPerson.name()},"//s:item/s:part/@value")' property='target.{ARQ:EnteredByPerson().FamilyName}' action='set' />
<assign value='source.{controlActProcess().subject().encounterEvent().location().serviceDeliveryLocation().serviceProviderOrganization.id().item().extension}' property='target.{ARQ:EnteredByLocation.Facility}' action='set' />
<assign value='##class(HCC.Utils.Functions).GetDataByXPath(source.{controlActProcess().subject().encounterEvent().location().serviceDeliveryLocation().location.name},"//s:item/s:part/@value")' property='target.{ARQ:EnteredByLocation.Room}' action='set' />
<assign value='source.{controlActProcess().subject().encounterEvent().admissionReferralSourceCode.displayName.value}' property='target.{PIDgrp().PV1:AdmissionType}' action='set' />
</transform>
}

}
